from threading import Thread
from time import sleep
import sys
import os

def fun1():
  varLastPrintLen = 0
  fun1.isStop = False
  with open('1.o.txt',mode='r') as var4:
    while main.isStopO == False:
      try:
        var3 = var4.read().encode("gbk", "ignore").decode("utf8","ignore")
        varPrint = var3
        if varPrint != '\n':
          print(varPrint,end='')
        varLastPrintLen = len(var3)
        sleep(0.1)
      except: pass
  print(fun1.var4[varLastPrintLen:],end='\n')
  fun1.isStop = True

def main():
  main.var2.seek(0)
  t1=Thread(target=fun1)
  var1 = input('> ').strip(' ')
  main.isStopO = False
  if var1 != '':
    t1.start()
    os.system(r"("+var1+r")>1.o.txt")
    fun1.var4 = main.var2.read().encode("gbk", "ignore").decode("gbk","ignore")
    main.isStopO = True
    while fun1.isStop == False:
      sleep(0.1)
  if var1 in ['cls', 'clear', 'reset']:
    for i in range(os.get_terminal_size().lines):
      print()

    #var2.write('')

os.system(r"echo;>1.o.txt")
os.chdir(os.path.dirname(os.path.abspath(__file__)))
with open('1.o.txt',mode='r') as main.var2:
  while True:
    main()
    os.system(r"echo;>1.o.txt")

